import 'package:flutter/material.dart';

class LoadingContainer extends StatelessWidget {
  Widget child;

  // 是否有loading动画
  bool loading;

  // 是否遮罩层
  bool cover;

  LoadingContainer(
      {@required this.child, @required this.loading, this.cover = false});

  _getWidget() {
    return Center(
      child: CircularProgressIndicator(),
    );
  }

  @override
  Widget build(BuildContext context) {
    return cover ? Stack(
            children: <Widget>[child, loading ? _getWidget() : Container()],
          ) : (loading ? _getWidget() : child);
  }
}
